(function() {

	var skill = {
		save: function() {
			db.update(config.dbname.buff, this._id, this);
		},
		destroy: function() {
			db.remove(config.dbname.buff, this._id);
		},
		//开启活动，为相关商品加上BUFF
		begin: function(argument) {},
		//冻结停止活动，冻结商品BUFF
		stop: function(argument) {},
		//结束活动，移除相关商品的相关BUFF
		end: function(args) {},
		//运作BUFF
		//args包含主要环境变量，包括：用户、商家、商品、订单、app
		emit: function(args) {
			var code = buffCode[this.code_id];
			if (!code) {
				throwCusError("找不到BUFF运作方式" + this.code_id)
			}
			return code.call(this, args);
		},
		//判断是否还有效
		isUseAble: function() {
			//如果没有限定时间，则默认有效
			if (!this.end_time) {
				return true
			}
			//过期则失效
			if (this.end_time > (+new Date)) {
				return true
			}
		},
		//是否真正在生效
		isEffecting: function() {
			//首先BUFF不可过期
			if (this.isUseAble()) {
				//没有限定开始时间，默认一直生效状态
				if (!this.begin_time) {
					return true
				}
				if (this.begin_time > (+new Date)) {
					return true
				}
			}
			return false;
		},
		setConfig: function(config) {
			this.config = config;
			this.save();
		}
	}
	module.exports = skill;
	var db = require("../db/index");
	var UserCon = require("./_con");
	var BusCon = require("../bus/_con");
	var GoodsCon = require("../goods/_con");
	var AchCon = require("../ach/_con");
	var PayAchCon = require("../pay_ach/_con");
	var CommentCon = require("../comment/_con");
	var EvaluationCon = require("../eval/_con");
	var ClassifyCon = require("./_con");
	var config = require("../_include/config");
	var data_cut = require("../_include/data_cut");
	var $Array = require("../_include/$.Array");
	var $Object = require("../_include/$.Object");
	var helper = require("../_include/helper");
	var buffCode = require("./buff_code");


}());